<template>
	<view class="main">
		<view class="top">
			<image class="img" :src="backgroundImg"></image>
			<image class="head_img" :src="headImg"></image>
			<view class="usr">{{username}} 的娱乐圈</view>
		</view>
		<view class="mid_nav">
			<view class="mid_nav_button_one">我的发表</view>
			<view class="mid_nav_button">微文精选</view>
			<view class="mid_nav_button">我的生涯</view>
			<view class="mid_nav_button">留言广场</view>
		</view>
		<popup-layer ref="popup" :direction="direction">
			<view class="menu_box">
				<view class="menu_list" @tap="add">添加事件</view>
				<view class="menu_list" @tap="report">发表心情</view>
				<view class="menu_list" @tap="signIn">每日签到</view>
				<view class="menu_list" @tap="share">推荐分享</view>
				<view class="menu_list_cancle" @tap="menu">取消</view>
			</view>
		</popup-layer>
		<view class="detail_list">
			这是一条动态1
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
		<view class="detail_list">
			这是一条动态
		</view>
	</view>

</template>

<script>
	import popupLayer from '../../components/popup-layer/popup-layer.vue';
	export default {
		components: {
			popupLayer
		},
		data() {
			return {
				maskIsShow: true,
				backgroundImg: "../../static/default.png",
				headImg: "../../static/head.jpg",
				username: '',
				direction: 'top',
				menuShow: false
			}
		},
		onLoad() {
			uni.getStorage({
				key: 'userInfo',
				success: (res) => {
					this.$data.username = res.data.userName;
					this.$data.headImg = res.data.userHimg;
				},
				fail: () => {
					uni.navigateTo({
						url: '/pages/my/login'
					})
				}
			})
		},
		onPullDownRefresh() {
			console.log("触发下拉刷新");
			console.log("正在刷新");
			setTimeout(function() {
				console.log("刷新完成");
				uni.stopPullDownRefresh();
			}, 3000);
		},
		onNavigationBarButtonTap(e) {
			switch (e.index) {
				case 0:
					this.menu();
					break;
				case 1:
					this.backToTop();
					break;
			}

		},
		onPageScroll() {

		},
		methods: {
			menu: function() {
				const pages = getCurrentPages();
				const page = pages[pages.length - 1];
				const currentWebview = page.$getAppWebview();
				currentWebview.setStyle({
					pullToRefresh: {
						support: this.menuShow,
					}
				});
				this.menu_cancle();
			},
			report: function() {
				uni.navigateTo({
					url: 'report'
				});
			},
			add: function() {
				uni.navigateTo({
					url: 'add'
				});
			},
			signIn: function() {
				uni.navigateTo({
					url: 'signIn'
				});
			},
			share: function() {
				uni.navigateTo({
					url: 'share'
				});
			},
			backToTop: function() {
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 500
				});
			},
			menu_cancle:function(){
				this.menuShow?this.$refs.popup.close():this.$refs.popup.show();
				this.menuShow = !this.menuShow;
			}
		}
	}
</script>

<style>
	@import url("../class/class.css");
</style>
